home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / system / mail / mailhand / metamail.z / metamail / bin / showpartial < prev    next >
Encoding:
Text File  |  1992-05-05  |  2.3 KB  |  87 lines

  1. #!/bin/csh -f
  2.  
  3. set TREEROOT=/tmp/message-parts-`whoami`
  4. if ($#argv < 3 || $#argv > 4) then
  5.     echo "Usage:  showpartial file id partnum totalnum"
  6.     exit -1
  7. endif
  8. set file=$1
  9. # This next line is because message-id can contain weird chars
  10. set id=`echo $2 | tr -d  \!\$\&\*\(\)\|\'\"\;\/\<\>\\` 
  11. @ partnum = $3
  12. if ($#argv == 3 || $4 == "") then
  13.     set totalnum=-1
  14. else
  15.     @ totalnum = $4
  16. endif
  17.  
  18. if (! -d  $TREEROOT)  then
  19.     mkdir $TREEROOT
  20.     if ($status) then 
  21.         echo mkdir $TREEROOT failed
  22.         exit -1
  23.     endif
  24. endif
  25. if (! -d ${TREEROOT}/$id) then 
  26.     mkdir ${TREEROOT}/$id
  27.     if ($status) then 
  28.         echo mkdir ${TREEROOT}/$id failed
  29.         exit -1
  30.     endif
  31. endif
  32. cp $file ${TREEROOT}/$id/$partnum
  33. if ($status) then 
  34.     echo cp $file ${TREEROOT}/$id/$partnum failed
  35.     exit -1
  36. endif
  37. if ($totalnum == -1) then
  38.     if (-e ${TREEROOT}/$id/CT) then
  39.     set totalnum=`cat ${TREEROOT}/$id/CT`
  40.     else
  41.         set totalnum=-1  #GROSS HACK
  42.     endif
  43. else
  44.     echo $totalnum >! ${TREEROOT}/$id/CT
  45. endif
  46. # Slightly bogus here -- the shell messes up the newlines in the headers
  47. # If you put $MM_HEADERS in quotes, it doesn't help.
  48. # if ($partnum == 1) then
  49. #     echo $MM_HEADERS > ${TREEROOT}/$id/HDRS
  50. # endif
  51. set found=0
  52. set ix=1
  53. set list=""
  54. set limit=$totalnum
  55. if ($limit == -1) set limit=25
  56. while ($ix <= $limit)
  57.     if (-e ${TREEROOT}/$id/$ix) then
  58.     set list="$list $ix"
  59.     @ found ++
  60.     endif
  61.     @ ix ++
  62. end
  63. if ($found == $totalnum) then
  64.     cd ${TREEROOT}/$id
  65.     cat $list > ${TREEROOT}/$id/FULL
  66. #    cat ${TREEROOT}/$id/HDRS $list > ${TREEROOT}/$id/FULL
  67.     rm $list
  68.     echo All parts of this ${totalnum}-part message have now been read.
  69.     metamail -d  ${TREEROOT}/$id/FULL
  70.     echo WARNING:  To save space, the full file is now being deleted.  
  71.     echo You will have to read all $totalnum parts again to see the full message again.
  72.     rm ${TREEROOT}/$id/FULL
  73.     rm ${TREEROOT}/$id/CT
  74. #    rm ${TREEROOT}/$id/HDRS
  75.     cd
  76.     rmdir ${TREEROOT}/$id
  77.     rmdir ${TREEROOT} >& /dev/null
  78. else
  79.     if (${totalnum} == -1) then
  80.         echo So far you have only read $found of the several parts of this message.
  81.     else
  82.         echo So far you have only read $found of the $totalnum parts of this message.
  83.     endif
  84.     echo When you have read them all, then you will see the message in full.
  85. endif
  86.     
  87.